package com.flca.frw.validator
{
	import mx.validators.Validator;
	import mx.validators.ValidationResult;
	import mx.controls.TextInput;
	import mx.controls.Text;

/*
    <mx:RadioButton groupName="rg2" id="rg2No" label="Nee" />
    <mx:TextInput id="idRg2HL" width="50" text="{rg2.selectedValue}" visible="false" color="red"/>

	<vld:RbValidator id="vldRg2" source="{rg2}" property="selectedValue" 
		required="true" enabled="false" highlight="{idRg2HL}"/>

*/	
	
	public class RbValidator extends Validator
	{
		[Inspectable]
		public var highlight : Text;
		
		private var results:Array;

		public function RbValidator () {
			super();
		}
		 
	    override protected function doValidation(value : Object):Array {
		    // Clear results Array.
		    results = [];
		
		    // Call base class doValidation().
		    results = super.doValidation(value);        
		    if (results.length > 0) {
		    	if (highlight != null) {
		    		highlight.text = '*';
		    		highlight.visible = true;
		    	}
		        return results;
		    }
		    
	    	if (highlight != null) {
	    		highlight.text = '';
	    		highlight.visible = false;
	    	}

		    return results;
		}
	}
}